import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
import {AtTabs,AtTabsPane,AtInput,AtButton} from 'taro-ui'
import {getGlobalData } from '../../../global';
import './minecard.css'
import reactMixin from 'react-mixin';
import myJs from './minecardJs.js'
import app from '../../../../main.js'

export default class MineCard extends Component {
    config = {
        navigationBarTitleText: '我的名片'
    }
    constructor () { 
        super(...arguments); 
        this.state = {
            doctor: {},
            qrcode: ''
        };
    }
    
    init () {
        this.getInfo();
        this.getQrcode();
    }

    getInfo() {
        let me = this;
        app.get('web/doctor/get', {}, function(res) {
            me.setState({
                doctor: res.data.result
            });
        });
    }

    getQrcode() {
        var me = this;
        app.get('web/doctor/getForPatientQrcodeByToken', {}, function(res) {
            me.setState({
                qrcode: res.data.result
            })
        });
    } 
   
    render () {
        return (
            <View className='mine-card'>
                <View className=' class_10'>
                    <View className=' class_11'>
                        <Text className=' class_12'>微信扫一扫关注{this.state.doctor.name}医生</Text>
                    </View>
                    <View className=' class_13'>
                        <Text className=' class_14'>随时随地都能问医生</Text>
                    </View>
                    <Image className=' class_15' src={app.getPath(this.state.qrcode)}></Image>
                    <View className=' class_16'>
                        <Text className=' class_17'>{this.state.doctor.name}</Text>
                    </View>
                    <View className=' class_18'>
                        <Text className=' class_19'>{this.state.doctor.positional_title+' '} | {this.state.doctor.department}</Text>
                    </View>
                    <View className=' class_20'>
                        <Text className=' class_21'>{this.state.doctor.hospital+this.state.doctor.department}医生</Text>
                    </View>
                </View>
                {/* <View className=' class_22'>
                    <View className=' class_23'>
                        <AtButton className=' class_24'>
                            <Text className='white-text'>下载名片</Text>
                        </AtButton>
                    </View>
                    <View className=' class_25'>
                        <AtButton className=' class_26'>
                            <Text className='white-text'>分享名片</Text>
                        </AtButton>
                    </View>
                </View> */}
            </View>
        );
    }
}
reactMixin.onClass(MineCard,myJs);